/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86183
 * Date: 2024-03-31
 * Time: 18:49
 */
public class Demo4 {
    public static int count=0;
    public static void main(String[] args) throws InterruptedException {
        Object locker=new Object();
        Thread thread=new Thread(()->{
            for (int i = 0; i < 100000; i++) {
                synchronized (locker){
                    count++;
                }

            }
        });
        thread.start();
        for (int i = 0; i < 100000; i++) {
            synchronized (locker){
                count++;
            }
        }
        Thread.sleep(1000);
        System.out.println("count = "+count);
    }
}
